﻿@namespace BootstrapBlazor.Components
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader]

<div @attributes="AdditionalAttributes" id="@Id" class="@ClassString" data-bb-zone-id="@ZoneId">
    <CascadingValue Value="this" IsFixed="true">
        @ChildContent
    </CascadingValue>
    <RenderTemplate>
        @foreach (var context in _contextMenuItems)
        {
            if (context is ContextMenuDivider)
            {
                <Divider></Divider>
                continue;
            }
            else if (context is ContextMenuItem item)
            {
                var disabled = GetItemTriggerClick(item);
                <DynamicElement @key="item" TagName="div" class="@GetItemClassString(disabled)"
                                TriggerClick="!disabled" OnClick="() => OnClickItem(item)">
                    <i class="@GetItemIconString(item)"></i>
                    <span>@item.Text</span>
                </DynamicElement>
            }
        }
    </RenderTemplate>
</div>
